package top.huntwolf.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.huntwolf.admin.common.JsonResult;
import top.huntwolf.admin.pojo.book.Book;
import top.huntwolf.admin.pojo.shop.BookShop;
import top.huntwolf.admin.service.ShopService;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/shop")
@Api(description = "店铺控制器")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @GetMapping()
    @ApiOperation("获取所有分店")
    public JsonResult<List<BookShop>> queryBookShop(){
        return JsonResult.success(shopService.searchBookShop());
    }

    @GetMapping("/longitude/{longitude}/latitude/{latitude}")
    @ApiOperation("根据位置获取最近书店")
    public JsonResult<BookShop> queryNearby(@PathVariable double longitude,@PathVariable double latitude){
        return JsonResult.success(shopService.searchRecentBookshop(longitude,latitude));
    }




}
